package com.freight.user.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.freight.core.base.FreightBaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.ColumnTransformer;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * @author huyingtai
 */
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "user_id_card")
@TableName("user_id_card")
@ApiModel(value = "身份证")
public class IdCard extends FreightBaseEntity {

    @ApiModelProperty(value = "联系人 --- 电话")
    private String contactPhone;

    @ApiModelProperty(value = "身份证号")
    @ColumnTransformer(read = "AES_DECRYPT(UNHEX(num),'freight')", write = "HEX(AES_ENCRYPT(?, 'freight'))")
    private String num;

    @ApiModelProperty(value = "姓名")
    private String name;

    @ApiModelProperty(value = "生日")
    private String birth;

    @ApiModelProperty(value = "性别")
    private String sex;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "身份证起始日期")
    private Date startDate;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "身份证结束日期")
    private Date endDate;

    @ApiModelProperty(value = "身份证前置照片地址")
    private String idCardFontPicFileId;

    @ApiModelProperty(value = "身份证后置照片地址")
    private String idCardBackPicFileId;

}